package artid.com.arttogo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import artid.com.arttogo.R;
import artid.com.arttogo.bean.IbeaconListParser;
import artid.com.arttogo.network.AppUtil;

/**
 * 
*    
* 项目名称：ArtworkArt   
* 类名称：SystemMessageAdapter   
* 类描述：系统消息适配器   
* 创建人：耿卫斌   
* 创建时间：2016-6-14 上午10:25:41   
*
 */
public class IbeconAdapter extends BaseAdapter {
	private Context mContext;
	private List<IbeaconListParser> list;
	
	public IbeconAdapter(Context mContext, List<IbeaconListParser> list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	public void notifyData(List<IbeaconListParser> list){
		this.list=list;
		notifyDataSetChanged();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		View v = convertView;
		if (v == null) {
			holder = new ViewHolder();
			v = LayoutInflater.from(mContext).inflate(R.layout.item_ibecan, null);
			holder.title=(TextView) v.findViewById(R.id.ib_title);
			holder.msg=(TextView) v.findViewById(R.id.ib_msg);
			holder.img=(ImageView) v.findViewById(R.id.ib_img);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		IbeaconListParser item = list.get(position);
		holder.title.setText(item.getMessactivitytitle());
		
		holder.msg.setText(item.getMessactivitycontent());
		Glide.with(mContext).load(item.getMessactivityimage()+ AppUtil.picWidthSmallUrl)
		.placeholder(R.drawable.ic_menu_rotate)
		.error(R.drawable.ic_menu_rotate).into(holder.img);
		
		return v;
	}
	class ViewHolder {
		TextView title,msg;
		ImageView img;
	}

}
